package com.zenkirin.divacrm.dao.hibernate;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.zenkirin.divacrm.dao.CustomerDAO;
import com.zenkirin.divacrm.model.Customer;

public class CustomerDaoHibernate extends HibernateDaoSupport implements
		CustomerDAO {

	@Override
	public void delete(Long id) {
		getHibernateTemplate().delete(getCustomer(id));

	}

	@Override
	public Customer getCustomer(Long id) {
		return (Customer) getHibernateTemplate().get(com.zenkirin.divacrm.model.Customer.class, id);
	}

	@Override
	public List getCustomers() {
		return getHibernateTemplate().find("from Customer order by id desc");
	}

	@Override
	public void save(Customer c) {
		getHibernateTemplate().saveOrUpdate(c);

	}

}
